package com.example.demo.service.impl;

import com.example.demo.entity.user.InsertUser;
import com.example.demo.entity.user.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    };

    @Override
    public int addUser(InsertUser insertUser) {
        return userMapper.addUser(insertUser.getName(), insertUser.getPassword(), insertUser.getType(),"admin",
            new Timestamp(new Date().getTime()));
    }
}
